<template>
	<view class="page" style="padding-bottom: 50upx;">
		<u-cell-group class="u-m-t-20">
			<u-cell-item title="同城展示" @click="showcity"></u-cell-item>
			<u-cell-item title="私信" @click="sixinset"></u-cell-item>
			<u-cell-item title="浏览和访客" @click="liulanset"></u-cell-item>
			<u-cell-item title="系统权限" @click="quanxian"></u-cell-item>
			<view class=""
				style="display: flex;align-items: center;justify-content: space-between;padding: 13px 0 13px 16px;">
				<view style="display: flex;flex-direction: column;flex: 1.5;">
					<text style="color: #333333;font-size: 30upx;">消息推送</text>
					<text style="color: #999999;font-size: 24upx;padding-top: 18upx;">当你关闭消息推送后，你将无法收到关于平台内的任何消息。</text>
				</view>
				<switch :checked="isflase" @change="xiaotui" color="#FF3D3D" style="transform:scale(0.7);" />
			</view>
			<view class=""
				style="display: flex;align-items: center;justify-content: space-between;padding: 13px 0 13px 16px;">
				<view style="display: flex;flex-direction: column;flex: 1.5;">
					<text style="color: #333333;font-size: 30upx;">个性化内容推荐</text>
					<text
						style="color: #999999;font-size: 24upx;padding-top: 18upx;">当你关闭个性化内容推荐后，你无法享受个性化推荐服务，你可能会看到你不感兴趣甚至不喜欢的内容。</text>
				</view>
				<switch :checked="isflase" @change="huan" color="#FF3D3D" style="transform:scale(0.7);" />
			</view>
		</u-cell-group>
		<uni-popup ref="cityshow" type="bottom">
			<view class="bot">
				<image src="../../dsxShop/static/closed.png" mode=""
					style="width: 26upx;height: 26upx;position: absolute;right: 30upx;top: 30upx;" @click="guanbi">
				</image>
				<view
					style="margin: 0 auto;width: 560upx;display: flex;flex-direction: column;align-items: center;justify-content: center;padding-top: 130upx;">
					<image src="../../dsxShop/static/cityzs.png" mode="" style="width: 98upx;height: 114upx;"></image>
					<text style="color: #333333;font-size: 36upx;font-weight: 550;padding-top: 32upx;">同城展示</text>
					<text style="color: #999999;font-size: 28upx;padding-top: 30upx;">关闭后，你的作品和直播将不会在同城页展示</text>
				</view>
				<view
					style="display: flex;width: 100%;justify-content: space-between;align-items: center;padding-top: 70upx;padding-left: 30upx;padding-right: 30upx;">
					<text style="color: #333333;font-size: 28upx;">同城展示作品、位置</text>
					<switch checked="true" @change="" color="#FF3D3D" />
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				currentSize: 0, //当前缓存大小
				Server: '',
				zclist: [],
				isflase: true,
				showBox: 0,
				serviceHotline: '',
				info: {}
			};
		},

		computed: {
			getuserInfo() {
				return this.$store.getters.getuserInfo
			}
		},
		onLoad() {
			this.$http.getreadprofile().then(res => {
				console.log(res, "微信登录没有走这里吗")
				this.info = res.data

			})

		},
		onShow() {
			this.getStorageInfoSync();
		},
		methods: {
			xiaotui(e) {
				if (e.detail.value == true) {
					var type_name = 'is_internal_mess'
				
					var type_id = 1
					this.$http.yinsiset({
						type_name,
						type_id
					}).then(res => {
						if (res.status == 200) {
							uni.showToast({
								title: '设置成功',
								icon: 'none'
							})
							this.info.is_push = 1
							this.serviceHotline = res.data.serviceHotline;
				
						}
					})
				} else {
					var type_name = 'is_internal_mess'
				
					var type_id = 0
					this.$http.yinsiset({
						type_name,
						type_id
					}).then(res => {
						if (res.status == 200) {
							uni.showToast({
								title: '设置成功',
								icon: 'none'
							})
							this.info.is_push = 1
							this.serviceHotline = res.data.serviceHotline;
				
						}
					})
				}
			},
			huan(e) {
				console.log(e.detail.value)



				if (e.detail.value == true) {
					var type_name = 'is_push'

					var type_id = 1
					this.$http.yinsiset({
						type_name,
						type_id
					}).then(res => {
						if (res.status == 200) {
							uni.showToast({
								title: '设置成功',
								icon: 'none'
							})
							this.info.is_push = 1
							this.serviceHotline = res.data.serviceHotline;

						}
					})
				} else {
					var type_name = 'is_push'

					var type_id = 0
					this.$http.yinsiset({
						type_name,
						type_id
					}).then(res => {
						if (res.status == 200) {
							uni.showToast({
								title: '设置成功',
								icon: 'none'
							})
							this.info.is_push = 1
							this.serviceHotline = res.data.serviceHotline;

						}
					})
				}
			},
			liulanset() {
				uni.navigateTo({
					url: './fangke'
				})
			},
			sixinset() {
				uni.navigateTo({
					url: './sxset'
				})
			},
			guanbi() {
				this.$refs.cityshow.close()
			},
			showcity() {
				this.$refs.cityshow.open()
			},
			quanxian() {
				uni.navigateTo({
					url: './stytemset'
				})
			},
			ysset() {
				uni.navigateTo({
					url: '../yinsiset'
				})
			},
			xao() {
				uni.navigateTo({
					url: '../xaohao'
				})
			},
			hideMask() {
				this.showBox = 0;
			},
			dail(tel) {
				uni.makePhoneCall({
					phoneNumber: tel
				})

			},
			getServiceHotline() {
				this.$http.getserviceHotline().then(res => {
					if (res.status == 200) {
						this.serviceHotline = res.data.serviceHotline;

					}
				})
			},
			showPopUpBox() {
				this.showBox = 1;
			},
			navigateTo(url) {
				this.$navigateTo(url);
			},

			// 退出登陆
			logout() {
				$utils.showModal({
					content: '确认退出账户吗?'
				}).then(res => {
					console.log("-> res", res);
					if (res.confirm) {
						uni.onSocketClose(function(res) {
							console.log('WebSocket 已关闭！');
						});
						uni.removeStorageSync('token');
						uni.removeStorageSync('device_token');
						uni.removeStorageSync('userInfo')
						this.$toast('退出登录成功');

						this.$u.route({
							url: "/pagesB/login/login",
							type: "reLaunch"
						})

					}
				})

			},
			// 获取缓存大小
			getStorageInfoSync() {
				uni.getStorageInfo({
					success: res => {
						this.currentSize = (res.currentSize / 1024).toFixed(2);
					}
				});
			},
			goAboutus(id, title) {
				// this.$u.route({url:'/pagesB/article/detail',params:{title:'关于我们'}{id:id}})
				uni.navigateTo({
					url: `/pagesB/article/detail?tilte=${title}&id=${id}`
				})
			},
			// 清除缓存
			clearStorage() {
				$utils.showModal({
					content: '确定要清除缓存吗?'
				}).then(res => {
					if (res.confirm) {
						try {
							uni.clearStorageSync();
							this.currentSize = 0
						} catch (e) {
							// error
						}
					}
				})

			}
		}
	};
</script>

<style lang="scss" scoped>
	.bot {
		background-color: #fff;
		width: 100%;
		height: 550upx;
		border-top-left-radius: 15px;
		border-top-right-radius: 15px;
		position: relative;
	}

	.popUpBox {
		position: fixed;
		width: 402upx;
		height: 452upx;
		background: #fff;
		z-index: 999;
		border-radius: 20upx;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);

		.tel {
			text-align: center;
			margin-top: -25upx;

			image {
				width: 174upx;
				height: 174upx;
			}
		}

		.text {
			line-height: 43upx;
			font-weight: bold;
			text-align: center;
		}

		.button {
			width: 247upx;
			height: 66upx;
			border-radius: 45upx;
			position: absolute;
			bottom: 36upx;
			left: 50%;
			transform: translate(-50%, 0)
		}

		.cancel {
			width: 53upx;
			height: 53upx;
			position: absolute;
			left: 50%;
			transform: translate(-50%, 0);
			bottom: -75upx;

			image {
				width: 100%;
				height: 100%;
			}
		}
	}

	@import "~uview-ui/index.scss";

	.logoutBtn {
		padding: 20upx;
		background-color: #fff;
		margin-top: 40upx;
		text-align: center;
		color: #666;
	}

	.title {
		font-size: 32upx;
		margin-bottom: 10upx;
	}

	.phone {
		font-size: 24upx;
		color: #999;
	}

	.avatarHead {
		background-color: #fff;
		border-bottom: 1px solid #f5f5f5;

		.right {
			position: absolute;
			right: 30upx;
			top: 50%;
			transform: translateY(-50%);
		}
	}
</style>
